﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace PropGridInfo
{
	public class PropComboItemConvert : ComboBoxItemTypeConvert
	{
		public override void GetConvertHash()
		{
			try
			{
				this.myhash = this.hash;
			}
			catch
			{
				throw new NotImplementedException();
			}
		}

		public int value { get; set; }

		public string GetValue()
		{
			bool flag = this.m_strCurValue == "";
			if (flag)
			{
				foreach (object obj in this.myhash)
				{
					DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
					int num = this.value;
					bool flag2 = !this.m_bConverse;
					if (flag2)
					{
						num = this.myhash.Count - 1 - this.value;
					}
					bool flag3 = dictionaryEntry.Key.Equals(num);
					if (flag3)
					{
						return dictionaryEntry.Value.ToString();
					}
				}
			}
			return this.m_strCurValue;
		}

		public PropComboItemConvert(string str, bool bConverse = false)
		{
			this.m_bConverse = bConverse;
			this.m_lstString = new List<string>();
			this.hash = new Hashtable();
			string[] array = str.Split(new char[]
			{
				','
			});
			for (int i = 0; i < array.Length; i++)
			{
				int num = i;
				bool flag = !bConverse;
				if (flag)
				{
					num = array.Length - 1 - i;
				}
				this.hash.Add(i, array[num]);
				this.m_lstString.Add(array[num]);
			}
			this.GetConvertHash();
			this.value = 0;
		}

		public PropComboItemConvert(string str, int s, bool bConverse = false) : this(str, bConverse)
		{
			this.value = s;
		}

		public PropComboItemConvert(List<string> strList, bool bConverse = false)
		{
			this.m_bConverse = bConverse;
			this.m_lstString = new List<string>();
			this.hash = new Hashtable();
			for (int i = 0; i < strList.Count; i++)
			{
				int index = i;
				bool flag = !bConverse;
				if (flag)
				{
					index = strList.Count - 1 - i;
				}
				this.hash.Add(i, strList[index]);
			}
			this.GetConvertHash();
			this.value = 0;
		}

		public PropComboItemConvert(List<string> strList, int s, bool bConverse = false) : this(strList, bConverse)
		{
			this.value = s;
		}

		public PropComboItemConvert(List<string> strList, string strSel, bool bConverse = false) : this(strList, bConverse)
		{
			this.value = strList.IndexOf(strSel);
		}

		private Hashtable hash;

		private List<string> m_lstString;
	}
}
